https://leetcode-cn.com/problems/first-unique-character-in-a-string/comments/

class Solution {
    public int firstUniqChar(String s) {
        int[] array = new int[26];
        for(char ch : s.toCharArray()){
            array[ch-97]++;
        }
        for (int i = 0; i < s.length(); i++) {
            if(array[s.charAt(i)-97] == 1){
                return i;
            }
        }
        return -1;
    }
}